package com.bsj.power.common.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bsj.power.common.def.dto.alarmReport.AlarmReportSearchDTO;
import com.bsj.power.common.def.entity.alarmReport.AlarmReport;
import com.bsj.power.common.def.entity.job.Job;
import com.bsj.power.common.def.vo.KeyValueVO;
import com.bsj.power.common.def.vo.pls.AlarmReportCountVO;
import com.bsj.power.common.def.vo.pls.AlarmReportVO;
import com.bsj.power.common.def.vo.homePage.AlarmTypeCountVO;
import com.bsj.power.common.def.vo.web.job.home.JobRank;
import com.bsj.power.common.def.vo.web.job.media.BackTimeMediaVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author LiJiaXin
 * @version 1.0.0
 * @description 设备报警、围栏报警等（报警综合）
 * @time 2024/4/25 17:30
 */
@Mapper
@Repository
public interface AlarmReportMapper extends BaseMapper<AlarmReport> {

    /**
     * 统计数量
     *
     * @param alarmReportSearchDTO
     * @return long
     * @author ljx
     * @time 2024/4/25 17:35
     */
    long countAlarmReport(AlarmReportSearchDTO alarmReportSearchDTO);

    /**
     * 报警报表
     *
     * @param alarmReportSearchDTO
     * @return java.util.List<com.bsj.power.common.def.vo.pls.AlarmReportCountVO>
     * @author ljx
     * @time 2024/4/25 17:35
     */
    List<AlarmReportCountVO> pageAlarmReportCount(AlarmReportSearchDTO alarmReportSearchDTO);


    /**
     * 统计报警详情数量
     *
     * @param alarmReportSearchDTO
     * @return long
     * @author ljx
     * @time 2024/5/13 10:23
     */
    long countAlarmReportDetail(AlarmReportSearchDTO alarmReportSearchDTO);

    /**
     * 报警详情
     *
     * @param alarmReportSearchDTO
     * @return java.util.List<com.bsj.power.common.def.vo.pls.AlarmReportVO>
     * @author ljx
     * @time 2024/5/13 10:24
     */
    List<AlarmReportVO> alarmReportDetail(AlarmReportSearchDTO alarmReportSearchDTO);

    /**
     * 批量查询设备的报警信息
     *
     * @param map
     * @return
     */
    List<AlarmReportVO> batchAlarmReportDetail(Map<String, Object> map);

    /**
     * 报警区域统计
     *
     * @param startTime
     * @param endTime
     * @return java.util.List<com.bsj.power.common.def.vo.KeyValueVO>
     * @author ljx
     * @time 2024/5/13 15:51
     */
    List<KeyValueVO> alarmAreaCount(@Param("startTime") String startTime, @Param("endTime") String endTime);

    /**
     * 报警区域统计
     *
     * @param alarmReportSearchDTO
     * @return java.util.List<com.bsj.power.common.def.vo.KeyValueVO>
     * @author ljx
     * @time 2024/5/14 11:08
     */
    List<KeyValueVO> alarmTimeCount(AlarmReportSearchDTO alarmReportSearchDTO);

    /**
     * 按报警类型分组统计报警数量
     *
     * @param startTime
     * @param endTime
     * @return java.util.List<com.bsj.power.common.def.vo.singleScreen.AlarmTypeCountVO>
     * @author ljx
     * @time 2024/6/7 20:21
     */
    List<AlarmTypeCountVO> groupCountByAlarmType(@Param("startTime") String startTime, @Param("endTime") String endTime);

    /**
     * 报警信息列表
     *
     * @param alarmType
     * @param startTime
     * @param endTime
     * @return java.util.List<com.bsj.power.common.def.vo.pls.AlarmReportVO>
     * @author ljx
     * @time 2024/6/11 14:08
     */
    List<AlarmReportVO> listAlarmInfo(@Param("alarmType") Integer alarmType, @Param("startTime") String startTime, @Param("endTime") String endTime);

    /**
     * 根据区域名称与时间统计报警数
     *
     * @param job
     * @return com.bsj.power.common.def.vo.web.job.home.JobRank
     * @author ljx
     * @time 2024/6/25 11:12
     */
    JobRank countByAreaAndTime(Job job);

    /**
     * 根据人员id集与作业时间统计报警数
     *
     * @param personnelIds
     * @param job
     * @return java.util.List<com.bsj.power.common.def.vo.web.job.home.JobRank>
     * @author ljx
     * @time 2024/6/25 10:48
     */
    List<JobRank> countByPersonnelAndTime(@Param("personnelIds") List<Integer> personnelIds, @Param("job") Job job);

    /**
     * 批量插入国标设备报警信息
     *
     * @param alarmReportList
     */
    void addAll(List<AlarmReport> alarmReportList);

    /**
     * 根据作业人员查询报警附件
     *
     * @param map
     * @return
     */
    List<BackTimeMediaVO> selectBatchWorkPersonnel(Map<String, Object> map);

    /**
     * 根据设备号查询未结束的报警类型
     *
     * @param deviceName
     * @return java.util.List<java.lang.Integer>
     * @author ljx
     * @time 2024/10/24 11:34
     */
    List<Integer> getAlarmTypeByDeviceName(String deviceName);
}
